package com.example.colorfulfog.service.table;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.colorfulfog.mapper.OrderTableRelationMapper;
import com.example.colorfulfog.model.OrderTableRelation;
import com.example.colorfulfog.service.table.interfaces.OrderTableRelationService;

@Service
public class OrderTableRelationServiceImpl extends ServiceImpl<OrderTableRelationMapper, OrderTableRelation> implements OrderTableRelationService {

    @Override
    public Map<String, List<OrderTableRelation>> getByOrderName(List<String> orderName) {
        return list(new LambdaQueryWrapper<OrderTableRelation>().in(
                OrderTableRelation::getOrderName, orderName)).stream().collect(Collectors.groupingBy(OrderTableRelation::getOrderTable));
    }

    @Override
    public List<OrderTableRelation> listByOrderName(List<String> orderName) {
        return list(new LambdaQueryWrapper<OrderTableRelation>().in(
                OrderTableRelation::getOrderName, orderName));
    }
}

